import 'package:flutter/material.dart';
import 'package:logger/logger.dart';
///    author : leo
///    e-mail : jkliao@yeah.net
///    date   : 2020-05-19
///    desc   :
class PageUtilTest extends StatefulWidget {
  static const rName = "PageUtilTest";
  @override
  _PageUtilTestState createState() => _PageUtilTestState();
}

class _PageUtilTestState extends State<PageUtilTest> with PageUtilTestBLOC {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(),
      body: _body(),
    );
  }

  Widget _body() {
    return Column(
      children: <Widget>[
        ListTile(
          title: Text("logger 插件"),
          onTap: () {
              demo();
          },
        )
      ],
    );
  }
}

mixin PageUtilTestBLOC on State<PageUtilTest> {

  var logger = Logger(
    printer: PrettyPrinter(),
  );

  var loggerNoStack = Logger(
    printer: PrettyPrinter(methodCount: 0),
  );

  void demo() {
    logger.d('Log message with 2 methods');

    loggerNoStack.i('Info message');

    loggerNoStack.w('Just a warning!');

    logger.e('Error! Something bad happened', 'Test Error');

    loggerNoStack.v({'key': 5, 'value': 'something'});

    Logger(printer: SimplePrinter(colors: true)).v('boom');
  }
}
